import json
import pyecharts as pye
f = open("./yq.txt","r",encoding="UTF-8")
data = json.loads(f.read())
henan_data_list = data["areaTree"][0]["children"][3]["children"]
henan_data = []
for x in henan_data_list:
    city_name = x["name"] + "市"
    city_confirm = x["total"]["confirm"]
    #print(city_confirm)
    henan_data.append((city_name,city_confirm))
print(henan_data)
map = pye.charts.Map()
map.add("确诊人数",henan_data,"河南")
map.set_global_opts(
    title_opts=pye.options.TitleOpts(title="河南省疫情地图"),
    visualmap_opts=pye.options.VisualMapOpts(
        is_show=True,           # 是否显示
        is_piecewise=True,      # 是否分段
        pieces=[
            {"min": 1, "max": 99, "lable": "1~99人", "color": "#CCFFFF"},
            {"min": 100, "max": 999, "lable": "100~9999人", "color": "#FFFF99"},
            {"min": 1000, "max": 4999, "lable": "1000~4999人", "color": "#FF9966"},
            {"min": 5000, "max": 9999, "lable": "5000~99999人", "color": "#FF6666"},
            {"min": 10000, "max": 99999, "lable": "10000~99999人", "color": "#CC3333"},
            {"min": 100000, "lable": "100000+", "color": "#990033"},
        ]
    )
)

map.render("河南某数据.html")